package com.enqualcomm.kids.mvp.login.phone.presenter;

import com.enqualcomm.kids.config.userdefault.AppDefault;
import com.enqualcomm.kids.mvp.login.phone.PhoneloginView;
import com.enqualcomm.kids.mvp.login.phone.model.PhoneLoginModel;
import com.enqualcomm.kids.mvp.login.phone.model.PhoneLoginModelImpl;
import com.enqualcomm.kids.network.socket.response.LoginResult;

/**
 * Created by Sunzhigang on 2016/9/12.
 */
public class Presenter implements onLoginListener {

    PhoneLoginModel model;
    PhoneloginView view;
    AppDefault appDefault;

    public Presenter(PhoneloginView view) {
        this.view = view;
        model = new PhoneLoginModelImpl();
        appDefault = new AppDefault();
    }


    public void Login(String username, String password, String country) {
        model.Login(username, password, country, this);
//        appDefault.setUsername(username);
    }

    @Override
    public void success(LoginResult response) {
        appDefault.setBbtreeUserid("abcdef1234567890");
        appDefault.setBbtreeUserPhoneNumber("13049365360");


        view.loginSuccess();
    }

    @Override
    public void failed(int code, String message) {
        view.loginFailed(message);
    }

    @Override
    public void failed(int code, int resID) {
        view.loginFailed(resID);
    }
}
